import request from '../utils/request';
import { PAGE_SIZE } from '../constants';

export function fetchDataMap(importInfo) {
    var data = new FormData()
    data.append('dataImport', JSON.stringify(importInfo))
    return request(`/api/DataMap`, {
        method: 'POST',
        body: data
    });
}

export function deleteUploadFile(fileName) {
    return request(`/api/Upload/Delete/${fileName}`, {
        method: 'POST'
    });
}

export function dataImport(importInfo, ignoreErr, errorDatas, dataMaps, isNewMap ) {
    var data = new FormData()
    data.append('dataImport', JSON.stringify(importInfo))
    data.append('ignoreErr', ignoreErr ? "true" : "false")
    data.append('errorDatas', JSON.stringify(errorDatas))
    if (dataMaps) {
        data.append('dataMaps', JSON.stringify(dataMaps))
    }
    data.append('isNewMap', isNewMap ? "true" : "false")
    return request(`/api/DataImport`, {
        method: 'POST',
        body: data
    });
}

export function dataProgress(fileName) {
    var data = new FormData()
    data.append('fileName', fileName)
    return request(`/api/DataImportProcess`, {
        method: 'POST',
        body: data
    });
}

